#include "air32f10x_conf.h"
#ifndef _DAC1_H_
#define _DAC1_H_

#define LIST_MAX_LEN 50
#define READ_N_BYTES 256

extern volatile uint8_t new_play_task;  // 新播放任务
extern volatile uint8_t last_task_done; // 上一个任务播放完成

enum SND_LIST
{
    SND_ZERO = 1,
    SND_ONE,
    SND_TWO,
    SND_THREE,
    SND_FOUR,
    SND_FIVE,
    SND_SIX,
    SND_SEVEN,
    SND_EIGHT,
    SND_NINE,
    SND_TEN,
    SND_BEEP1,
    SND_BEEP2,
    SND_MINITER,
    SND_POINT,
    SND_READY,
    SND_SECOND,
    SND_TEC,
    SND_261HZ,
    SND_293HZ,
    SND_329HZ,
    SND_349HZ,
    SND_392HZ,
    SND_440HZ,
    SND_493HZ,
    SND_523HZ,
    SND_587HZ,
    SND_659HZ,
    SND_698HZ,
    SND_783HZ,
    SND_880HZ,
    SND_987HZ,
    SND_1046HZ,
    SND_1174HZ,
    SND_1318HZ,
    SND_1396HZ,
    SND_1567HZ,
    SND_1760HZ,
    SND_1975HZ,
    SND_2093HZ
};

void dac1_init(void);
void dac1_gpio_init(void);
void dac1_dma_init(void);
void dac1_read_flash_sound_list();
void dac1_play(uint32_t flash_addr, uint32_t size, uint8_t wait);
void dac1_play_by_index(uint32_t index, uint8_t wait);
void dac1_play_n_ms_by_index(uint32_t index, uint32_t n_ms, uint8_t wait);
void dac1_continue_play_sound();
void dac1_play_digit(uint16_t n);
void speak_time(uint32_t time_of_10ms);

__STATIC_FORCEINLINE uint8_t dac1_has_new_task()
{
    return new_play_task;
}

__STATIC_FORCEINLINE uint8_t dac1_last_task_done()
{
    return last_task_done;
}

#endif // !_DAC1_H_